﻿using DLUProject.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ColorLife.Core.Helper;
using DLUProject.Domain;
public partial class Shared_Modules_WorkGroupModule : BaseUserControl
{
    public IServices<Systems> _service { get; set; }
    public IServices<WorkGroup> _workGroup { get; set; }

    private int ID
    {
        get
        {
            if (Request.QueryString["SystemID"] != null)
                return Server.UrlEncode(Request.QueryString["SystemID"]).ToInt();
            return -1;
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (ID > 0)
        {
            Session["SystemID"] = ID;
        }
        if (ID==-1)
        {                       
          //  rptWorkGroup.DataSource = _workGroup.GetBySystemID(Session["SystemID"].ToInt()).Where(c=>c.ParentID==0);
            rptWorkGroup.DataSource = _workGroup.All().Where(c => c.SystemID == Session["SystemID"].ToInt());
            rptWorkGroup.DataBind();
        }
        else
        {
            rptWorkGroup.DataSource = _workGroup.All().Where(c => c.SystemID == ID).Where(c => c.ParentID == 0);
            rptWorkGroup.DataBind();
        }
    }
    public string GetPortalUrl(object url)
    {
        return UrlHelper.PortalURL + url;
    }
}